package be.js.sqlCodeGenerator;

import java.io.FileInputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 *  
 * Launches the sql code generator for the parameters stored
 * in the properties file.
 * 
 * $Id: Main.java 83 2013-03-12 21:27:49Z johan.schamp@gmail.com $ 
 * @author johan schamp (johan.schamp@gmail.com)
 * 
 */
public class Main {

	public final static Logger LOGGER = Logger.getLogger(Main.class);
	public final static String VERSION = "V1.0.1";
	public final static String RELEASE_DATE = "20130312";
	public final static String REVISION = "83";
	
	public static void main(String[] args) {

		Properties properties = new Properties();

		try {
			properties.load(new FileInputStream("sqlCodeGenerator.properties"));

			SQLCodeGenerator codeGenerator = new SQLCodeGenerator(
					properties.getProperty("driver"),
					properties.getProperty("connection"), 
					properties.getProperty("user"), 
					properties.getProperty("password"), 
					properties.getProperty("schema").toUpperCase(),
					properties.getProperty("tablePattern").toUpperCase(),
					properties.getProperty("columnPattern").toUpperCase(),
					properties.getProperty("templateFile"),
					properties.getProperty("templateClass"),
					properties.getProperty("generatedFilePrefix")
					);
			LOGGER.info("CodeGenerator started.");
			codeGenerator.generate();
			LOGGER.info("CodeGenerator ended.");

		} catch (Exception e) {
			LOGGER.error(e, e);
		}		

	}

}
